﻿
#include "common_include.hpp"
#include "camera.hpp"
#include "transfer.hpp"

Camera::Ptr camera_ = nullptr;
Transfer::Ptr transfer_ = nullptr;
uint8_t  start_buf[3] = {0xfe,0xfd,0xfc};
uint8_t  stop_buf[3] = {0xfc,0xfd,0xfe};

int main()
{
    int n = 0;
    camera_ = Camera::Ptr(new Camera);
    transfer_ = Transfer::Ptr(new Transfer);
            
    sleep(5);

    if(transfer_->fd<0)
        exit(0);
    else{
        n = write(transfer_->fd,start_buf,3);
        printf("start : n = %d\n\r",n);
        // sleep(1);
        // n = write(transfer_->fd,start_buf,3);
        // printf("n = %d\n\r",n);
        // sleep(1);
        // n = write(transfer_->fd,start_buf,3);
        // printf("n = %d\n\r",n);
        // sleep(1);
    }
    while(1){
        usleep(1);
        if(camera_->pic_index>=1000){ 
            n = write(transfer_->fd,stop_buf,3);
            printf("stop : n = %d\n\r",n);
            exit(0);
        }    
    }
    return 0;
}

